﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.IO;
public class CreatePath : Editor
{
  static  string ClassStr = @"using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public static  class UIConstant 
{
//Content
}
";
    static string ReplaceStr = "//Content";
    [MenuItem("Path/CreateUIPath")]
    public static void CreateUIPaths()
    {
        string path =PathConst.PrefabPath;
        string []Dirs = Directory.GetDirectories(path);
        Dictionary<string, string> PathDic = new Dictionary<string, string>();
        foreach (var item in Dirs)
        {

            foreach (var file in Directory.GetFiles(item))
            {
                if (!file.EndsWith(".meta"))
                {
                    string name = PathHelp.GetUIPath(file);
                    PathDic.Add(name.Substring(name.IndexOf("/") + 1), name);
                }
            }
        }
        string Content = "";
        foreach (var item in PathDic)
        {
            string row="    public const string "+item.Key+" = \""+item.Value + "\";\n";
            Content += row;
        }
        string cStr = ClassStr.Replace(ReplaceStr, Content);
        File.WriteAllText(Application.dataPath + "/Project/Scripts/AutoScripts/" + "UIConstant.cs",cStr);
        AssetDatabase.Refresh();
    }
    [MenuItem("Assets/CopyAssetPath")]
    public static void CopyPath()
    {
       string path = AssetDatabase.GetAssetPath(Selection.activeObject);
        Debug.Log(path);
         GUIUtility.systemCopyBuffer = path.Replace("Assets",""); 
    }
    [MenuItem("Assets/Create/CreateUIClass")]
    public static void CreateClass()
    {
        string path = AssetDatabase.GetAssetPath(Selection.activeObject);
        if (Selection.activeGameObject != null)
        {
            
        }
      
    }
}
